package com.epoint.configuration;

import com.epoint.springtest.Pet;
import com.epoint.springtest.User;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 但凡以后看到 XXXAutoConfiguration 都意味着是Spring替我们自动配置，自动加载组件到Spring IOC容器里
 * 但是一般会配有 @Conditionalxxxxx @Importxxxx 等注解所修饰
 */
//@ConditionalOnClass
@Configuration(proxyBeanMethods = true)
public class Configuration2 {

    @Bean
    public Pet pet002(){
        Pet pet = new Pet();
        pet.setName("小猪222");
        return pet;
    }

    @Bean
    public User User002(Pet petParam){
        Pet pet = pet002();
        System.out.println("pet：" + pet.hashCode());

        System.out.println("petParam：" + petParam.hashCode());
        return new User("纪宽豪222", 27, null);
    }

//    public Configuration2() {
//        System.out.println("调用~~~~~~1");
//    }

//    public Configuration2(Pet pet, User user) {
//        System.out.println("调用~~~~~~2");
//        System.out.println("Configuration2有参构造======");
//        System.out.println("pet：" + pet.hashCode());
//        System.out.println("user：" + user.hashCode());
//    }

}
